//
//  SISSHouseLayoutDrawingCollectionViewCell.m
//  SISSAPP
//
//  Created by 袁应荣 on 2018/10/29.
//  Copyright © 2018年 优房网. All rights reserved.
//

#import "SISSHouseLayoutDrawingCollectionViewCell.h"
#import <SDWebImage/UIImageView+WebCache.h>

@interface SISSHouseLayoutDrawingCollectionViewCell ()

/// imageView
@property (weak, nonatomic) UIImageView *imageView;
/// infoLabel
@property (weak, nonatomic) UILabel *infoLabel;
@property (weak, nonatomic) UILabel *sellStatusLabel;

@end
@implementation SISSHouseLayoutDrawingCollectionViewCell

- (void)setModel {
    
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:@""] placeholderImage:[UIImage imageNamed:@"图片加载占位符"]];
    self.infoLabel.text = @"2室2厅2卫-89㎡";
    NSString *str = @"售罄";
    self.sellStatusLabel.text = [NSString stringWithFormat:@"【%@】",str];
    if (self.sellStatusLabel.text) {
        NSMutableAttributedString *mAttributedStr = [[NSMutableAttributedString alloc] initWithString:self.sellStatusLabel.text];
        [mAttributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(1, 2)];
        self.sellStatusLabel.attributedText = mAttributedStr;
    }
}

- (void)initUI {
    [super initUI];
    
    UIImageView *imageView = [[UIImageView alloc] init];
    imageView.image = [UIImage imageNamed:@"图片加载占位符"];
    [self.contentView addSubview:imageView];
    self.imageView = imageView;
    
    UILabel *infoLabel = [UILabel yyr_labelWithText:@"2室2厅2卫-89㎡" fontSize:15 textColor:MAIN_TEXT_COLOR];
    [self.contentView addSubview:infoLabel];
    self.infoLabel = infoLabel;
    
    UILabel *sellStatusLabel = [UILabel yyr_labelWithText:@"【在售】" fontSize:15 textColor:MAIN_TEXT_COLOR];
    [self.contentView addSubview:sellStatusLabel];
    self.sellStatusLabel = sellStatusLabel;
}

- (void)initConstraint {
    [super initConstraint];
    
    WeakSelf
    [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(weakSelf.contentView);
        make.height.mas_equalTo(10 * globelMargin);
    }];
    
    [self.infoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(weakSelf.contentView);
        make.top.equalTo(weakSelf.imageView.mas_bottom).offset(0.5 * globelMargin);
    }];
    
    [self.sellStatusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(weakSelf.contentView);
        make.top.equalTo(weakSelf.infoLabel.mas_bottom).offset(0.5 * globelMargin);
        make.bottom.equalTo(weakSelf.contentView).offset(-globelMargin);
    }];
    
    [self setModel];
}

@end
